package com.shujia.spark

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object DEmo13Sort {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf()
      .setAppName("make")
      .setMaster("local")


    val sc = new SparkContext(conf)


    val listRDD: RDD[Int] = sc.parallelize(List(1, 2, 3, 4, 1, 1, 2, 4, 1, 2, 4, 1, 5, 6, 4, 3))

    /**
      * sortBy 通过某一个列进行排序, 可以指定升序或者降序
      *
      */

    val sortRDD: RDD[Int] = listRDD.sortBy(i => i, ascending = false)

    sortRDD.foreach(println)

  }

}
